<?php

//防止恶意调用
if (!defined('IN_MOD'))
{
    die('Hacking attempt');
}

/** 限模板配置说明**************************************************
** return $datahtml 字符串形式返回则追加HTML
** return array('datahtml' => $listdatahtml) 数组形式返回则覆盖HTML
****************************************************************/

// 【回调函数钩子】测试模块-扩展模块参数-列表参数
function hook_article_list_paralist_testmodule($getdata)
{
	// 列表模块参数配置
	foreach($getdata['parainfolist'] as $key=>$val)
	{
		// 发布状态
		if($getdata['parameteradmin'][$key]['para'] == "post_status")
		{
			$getdata['parainfolist'][$key] = $val == 1 ? "已发布" : "未发布";	
		}
	}
	
	return $getdata;
}

// 【回调函数钩子】测试模块-扩展模块参数-文章数据其它基本参数
function hook_article_baseparameter1_testmodule($getdata)
{
	global $configinfo;
	
	$parahtml = '<tr>
					<th><b>模块追加</b></th>
				</tr>
				<tr>
					<td>
						<div style="text-align:center;">
							模块追加
							<p style="word-break:break-all;">配置目录：themes\simpleboot3\modulepara\configmodule\configmodulepara\hook\module\configmodulepara\model.php</p>
						</div>
					</td>
				</tr>';
	
	return $parahtml;
}

// 【回调函数钩子】测试模块-扩展模块参数-文章数据其它基本参数
function hook_article_baseparameter2_testmodule($getdata)
{
	global $configinfo;
	
	$parahtml = '<tr>
					<th>模块钩子</th>
					<td>
						<div style="background: #ecf7ff; border: 1px solid #bcddf7; padding: 10px; color:#0066b5; border-radius: 5px;">配置其它钩子参数 模块ID：'.$configinfo['moduleid'].'
						<p style="word-break:break-all;">配置目录：themes\simpleboot3\modulepara\configmodule\configmodulepara\hook\module\configmodulepara\model.php</p>
						</div>
					</td>
				</tr>';
	
	return $parahtml;
}

// 【回调函数钩子】系统配置-栏目模块配置-文章数据其它基本参数
function hook_article_baseparameter1_columnconfig($getdata)
{
	global $configinfo;
	
	$post_status_checked = $getdata['post']['post_status'] == 1 ? "checked" : "";
	
	$deschtml = htmlzst('
<html>
{$data},{$person[test]},{$para[test][test1]}
<$data>,<$person[test]>,<$para[test][test1]>
($data),($person[test]),($para[test][test1])
<php>echo "支持原生PHP代码";</php>
<php>foreach($testdata as $key=>$val){</php>
支持原生PHP代码，循环测试代码
<php>}</php>
列表一：<br/>
<ul>
  {foreach $arr1}
  <li>{v}</li>
  {/foreach}
</ul>
<br/>
列表二：<br/>
<ul>
  {loop $arr2}
  <li>{v}</li>
  {/loop}
</ul>
列表三：<br/>
<ul>
  {foreach $parameter[a][b]}
  <li>{v[a][b]}</li>
  {/foreach}
</ul>
{if $a == "1"}
a等于1
{elseif $a == "2"}
a等于2
{else}
a不等于1也不等于2
{/if}
</html>
	');
	$parahtml = '<tr>
					<th>配置状态</th>
				</tr>
				<tr>
					<td>
						<div class="checkbox">
							<label>
								<input type="checkbox" id="post-status-checkbox" name="post[post_status]" value="1" '.$post_status_checked.'>开启配置，使用当前配置的信息
								<span id="post-status-error" style="color: red;display: none"></span>
							</label>
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div style="background: #ecf7ff; border: 1px solid #bcddf7; padding: 10px; color:#0066b5; border-radius: 5px;">
							<p>模块参数contenthtml模板解析调用格式</p>
							<style>@media (max-width:1689px){
								.deschtml{width:285px;overflow-x:auto;}
							}</style>
							<pre class="st-lin15 deschtml">'.$deschtml.'</pre>
						</div>
					</td>
				</tr>';
	
	return $parahtml;
}

// 【回调函数钩子】订购管理-订单列表-列表参数
function hook_article_list_paralist_shoporder($getdata)
{
	// 列表模块参数配置
	foreach($getdata['parainfolist'] as $key=>$val)
	{
		// 下单时间
		if($getdata['parameteradmin'][$key]['para'] == "create_time")
		{
			$getdata['parainfolist'][$key] = date("Y-m-d H:i:s", $val);
		}
		
		// 订单状态
		if($getdata['parameteradmin'][$key]['para'] == "orderstatus")
		{
			$getdata['parainfolist'][$key] = $val == 2 ? "已付款，已发货" : ($val == 1 ? "已付款，待发货" : "未付款，未发货");
			if($getdata['listinfo']['integralok'] == 1)
			{
				$getdata['parainfolist'][$key] .= "<span class='promote".$getdata['listinfo']['id']."'>
				<script>$('.promote".$getdata['listinfo']['id']."').parent().parent().find('.listtitle').prepend('<font color=\"red\">【积分兑换】</font>');</script>";
			}
		}
		
		// 店铺名
		if($getdata['parameteradmin'][$key]['para'] == "shop_name")
		{
			$shopbase = getplatshopbaseinfo($getdata['listinfo']['supplier_id']);
			$getdata['parainfolist'][$key] = "<a href='".$shopbase['shop_url']."' target='_blank'>".$shopbase['shop_name']."</a>";
		}
	}
	
	return $getdata;
}

// 【回调函数钩子】订购管理-订单列表-列表HTML
function hook_article_listdatahtml_shoporder($getdata)
{
	// 订单商品
	$modulewhere=array();
	$modulewhere["tablename"]="modulepara_order_goods";
	$modulewhere["arrayclass"]=$getdata['id'];
	$modulewhere["bigclassname"]="orderid";
	$modulewhere["order"]='default';
	$ordergoodslist=modulepara("configmodule",$modulewhere,1);
	foreach($ordergoodslist as $key=>$val)
	{
		$goods_attr = getstrtoarr(",",$val['goods_attr']);
		foreach($goods_attr as $k=>$v)
		{
			$pinfo = getstrtoarr("-",$v);
			$ordergoodslist[$key]["goods_attr_arr"][$pinfo[0]] = $pinfo[1];
		}
	}
		
	$ordergoodshtml = '<table cellpadding="2" cellspacing="1" border="0" width="100%" class="order_table">
						<tbody><tr>
						<td>商品名称</td>
						<td width="12%">商品货号</td>
						<td width="15%">商品单价</td>
						<td width="15%">赠送积分</td>
						<td width="10%">商品数量</td>
						</tr>';
	 foreach($ordergoodslist as $key=>$val)
	 {					
	     $ordergoodshtml .= '<tr>
							<td><a href="'.cmf_url('portal/Article/index',array('id'=>$val['listid'],'cid'=>$val['listcatid'])).'" title="'.$val['goods_name'].'" target="_blank"><img src="/upload/'.$val['goods_img'].'" style="float:left; margin-right:10px;" width="50" height="50"> 
							<p>'.$val['goods_name'].'</p>
							<p>';
		foreach($val['goods_attr_arr'] as $k=>$v)
	    {
			$ordergoodshtml .= '<span style="color:#888;">'.$k.'：'.$v.' | </span>';
		}
		$ordergoodshtml .= '</p>  
							</a></td>
							<td>'.$val['goods_sn'].'</td>
							<td>￥'.$val['price'].'</td>
							<td>'.$val['giveintegral'].' 积分</td>
							<td>'.$val['number'].'</td>
							</tr>';
	 }
	$ordergoodshtml .= '</tbody></table>';
	
	return $ordergoodshtml;
}

// 【回调函数钩子】供应商管理-供应商列表-列表参数
function hook_article_list_paralist_shoplist($getdata)
{
	// 列表模块参数配置
	foreach($getdata['parainfolist'] as $key=>$val)
	{
		// 店铺LOGO
		if($getdata['parameteradmin'][$key]['para'] == "shop_logo")
		{
			$shopbase = getplatshopbaseinfo($getdata['listinfo']['supplier_id']);
			$getdata['parainfolist'][$key] = '<img class="shop_logo'.$getdata['listinfo']['id'].'" src="/upload/'.$val.'" width="60" height="60" />'.
			"<script>$('.shop_logo".$getdata['listinfo']['id']."').parent().parent().find('.listtitle').attr('href','".$shopbase['shop_url']."');</script>";
		}
	}
	
	return $getdata;
}

// 【回调函数钩子】系统配置-栏目参数-列表参数
function hook_article_list_paralist_columnpara($getdata)
{
	// 列表模块参数配置
	foreach($getdata['parainfolist'] as $key=>$val)
	{
		// 参数分类
		if($getdata['parameteradmin'][$key]['para'] == "classtype")
		{
			$columnid = moduleaqvarval('attrid','intval');
			$classtypedata = getclasstypedata($columnid,$columnid);
			$classtypedata = $classtypedata['data'];
			foreach($classtypedata as $keyclass=>$valclass)
			{
				if($val == $keyclass)
				{
					$classtypehtml = $valclass;
				}
			}
			$getdata['parainfolist'][$key] = $classtypehtml;	
		}
		
		// 参数类型
		if($getdata['parameteradmin'][$key]['para'] == "type")
		{
			if($val == 0)$typehtml = '简短';
			if($val == 1)$typehtml = '下拉';
			if($val == 2)$typehtml = '文本';
			if($val == 3)$typehtml = '多选';
			if($val == 4)$typehtml = '附件';
			if($val == 5)$typehtml = '单选';
			if($val == 6)$typehtml = '图片';
			if($val == 7)$typehtml = '数字';
			if($val == 8)$typehtml = '自定义';
			$getdata['parainfolist'][$key] = $typehtml;	
		}
		
		// 参数选项
		if($getdata['parameteradmin'][$key]['para'] == "attrinfo")
		{
			$getdata['parainfolist'][$key] = "<div style='height:28px; line-height:28px; width:95%; overflow: hidden; text-overflow:ellipsis; white-space: nowrap;' title='".$val."'>".$val."</div>";	
		}
		
		// 必填
		if($getdata['parameteradmin'][$key]['para'] == "condition")
		{
			if($val == 0)$conditionhtml = '否';
			if($val == 1)$conditionhtml = '是';
			$getdata['parainfolist'][$key] = $conditionhtml;	
		}
		
		// 推荐
		if($getdata['parameteradmin'][$key]['para'] == "recok")
		{
			if($val == 0)$recokhtml = '否';
			if($val == 1)$recokhtml = '是';
			$getdata['parainfolist'][$key] = $recokhtml;	
		}
		
		// 筛选
		if($getdata['parameteradmin'][$key]['para'] == "searchok")
		{
			if($val == 0)$searchokhtml = '否';
			if($val == 1)$searchokhtml = '是';
			$getdata['parainfolist'][$key] = $searchokhtml;	
		}
	}
	
	return $getdata;
}


// 【回调函数钩子】系统配置-订购参数-列表参数
function hook_article_list_paralist_shoppara($getdata)
{
	// 列表模块参数配置
	foreach($getdata['parainfolist'] as $key=>$val)
	{
		// 参数选项
		if($getdata['parameteradmin'][$key]['para'] == "attrinfo")
		{
			$getdata['parainfolist'][$key] = "<div style='height:28px; line-height:28px; width:95%; overflow: hidden; text-overflow:ellipsis; white-space: nowrap;' title='".$val."'>".$val."</div>";	
		}		
	}
	
	return $getdata;
}

// 【回调函数钩子】系统配置-优惠促销-列表参数
function hook_article_list_paralist_youhuicx($getdata)
{
	// 列表模块参数配置
	foreach($getdata['parainfolist'] as $key=>$val)
	{
		// 活动类型
		if($getdata['parameteradmin'][$key]['para'] == "hdtype")
		{
			if($val == 0)$hdtypehtml = '所有商品';
			if($val == 1)$hdtypehtml = '指定商品';
			$getdata['parainfolist'][$key] = $hdtypehtml;	
		}	
		
		// 优惠类型
		if($getdata['parameteradmin'][$key]['para'] == "yhhdtype")
		{
			if($val == 0)$yhhdtypehtml = '满额立减';
			if($val == 1)$yhhdtypehtml = '满额打折';
			$getdata['parainfolist'][$key] = $yhhdtypehtml;	
		}	
		
		// 需要满足的金额
		if($getdata['parameteradmin'][$key]['para'] == "tomoney")
		{
			$getdata['parainfolist'][$key] = "￥".$val;	
		}	
		
		// 活动金额
		if($getdata['parameteradmin'][$key]['para'] == "yhmoney")
		{
			$val = $getdata['listinfo']['yhhdtype'] == 1 ? "活动折扣：打".$getdata['listinfo']['expression']."折" : "立减金额：￥".$val;
			$getdata['parainfolist'][$key] = $val;	
		}	
	}
	
	return $getdata;
}

// 【回调函数钩子】系统配置-优惠券-列表参数
function hook_article_list_paralist_youhuijuan($getdata)
{
	// 列表模块参数配置
	foreach($getdata['parainfolist'] as $key=>$val)
	{
		// 活动类型
		if($getdata['parameteradmin'][$key]['para'] == "hdtype")
		{
			if($val == 0)$hdtypehtml = '所有商品';
			if($val == 1)$hdtypehtml = '指定商品';
			$getdata['parainfolist'][$key] = $hdtypehtml;	
		}	
		
		// 需要满足的金额
		if($getdata['parameteradmin'][$key]['para'] == "tomoney")
		{
			$getdata['parainfolist'][$key] = "￥".$val;	
		}	
		
		// 活动金额
		if($getdata['parameteradmin'][$key]['para'] == "yhmoney")
		{
			$getdata['parainfolist'][$key] = "￥".$val;	
		}	
	}
	
	return $getdata;
}

// 【回调函数钩子】系统配置-产品中心-列表参数
function hook_article_list_paralist_product($getdata)
{
	// 列表模块参数配置
	foreach($getdata['parainfolist'] as $key=>$val)
	{
		// 是否促销
		if($getdata['parameteradmin'][$key]['para'] == "promotestatus")
		{
			if($val == 0)$promotehtml = '否';
			if($val == 1)$promotehtml = '<span class="promote'.$getdata['listinfo']['id'].'">是</span>'."<script>$('.promote".$getdata['listinfo']['id']."').parent().parent().find('.listtitle').css('color','red');</script>";
			$getdata['parainfolist'][$key] = $promotehtml;	
		}	
		
		// 本店价格
		if($getdata['parameteradmin'][$key]['para'] == "price")
		{
			$getdata['parainfolist'][$key] = "￥".$val;	
		}	
	}
	
	return $getdata;
}

// 【回调函数钩子】测试模块-扩展模块参数-列表参数
function hook_article_list_paralist_columnconfig($getdata)
{
	// 列表模块参数配置
	foreach($getdata['parainfolist'] as $key=>$val)
	{
		// 发布状态
		if($getdata['parameteradmin'][$key]['para'] == "tplconfig")
		{
			$getdata['parainfolist'][$key] = $val == 1 ? "模板目录" : "程序目录";	
		}
	}
	
	return $getdata;
}

// 【回调函数钩子】测试模块-扩展模块参数-列表HTML
function hook_article_listdatahtml_testmodule($getdata)
{
	
	
	return $getdata;
}
?>